<script>
export default {
	globalData: {
		safeArea: 0
	},

	onLaunch: function () {
		let _this = this;
		uni.getSystemInfo({
			success(res) {
				_this.globalData.safeArea = res.safeAreaInsets.bottom;
				let token = uni.getStorageSync('access_token');
				let times = uni.getStorageSync('times');
				// 登录过期检测
				if (token) {
					if (times < _this.dayjs().unix()) {
						uni.clearStorageSync();
					}
				}
			}
		});
		// 新版本检测
		if (uni.canIUse('getUpdateManager')) {
			const updateManager = uni.getUpdateManager();
			updateManager.onCheckForUpdate(function (res) {
				if (res.hasUpdate) {
					updateManager.onUpdateReady(function (res) {
						uni.showModal({
							title: '更新提示',
							content: '新版本已经准备好，是否重启应用？',
							success(res) {
								if (res.confirm) {
									updateManager.applyUpdate();
								}
							}
						});
					});
				}
				updateManager.onUpdateFailed(function (res) {
					uni.showModal({
						title: '检测到新版本',
						content: '新版本已发布，请您删除当前小程序，重新搜索打开。'
					});
				});
			});
		} else {
			uni.showModal({
				title: '提示',
				content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
			});
		}
	}
};
</script>

<style lang="scss">
/*每个页面公共css */
page {
	background: $uni-bg-color;
}
button {
	font-size: 32rpx;
}
button[type='primary'] {
	background: $uni-primary !important;
}
button[disabled][type='primary'] {
	background: $uni-info !important;
}
.empty {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	padding: 100rpx 0;
	.image {
		display: block;
		width: 480rpx;
		height: 360rpx;
	}
	.emptyWord {
		font-size: 28rpx;
		color: $uni-secondary-color;
		text-align: center;
	}
}
.addBtn {
	position: fixed;
	z-index: 11;
	right: 40rpx;
	bottom: 100rpx;
	width: 110rpx;
	height: 110rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	background: $uni-primary;
	border-radius: 100%;
	border-width: 0;
	box-shadow: 0 1px 8px 1px rgba(165, 165, 165, 0.2);
}
.hoverClass {
	background-color: #f1f1f1 !important;
}
</style>
